﻿/*
最大公约数 
Time Limit:1000MS  Memory Limit:32768K


Description:
求两个正整数的最大公约数。

Input:
输入数据含有不多于50对的数据，每对数据由两个正整数(0 < n1,n2 < 2^32)组成。 
Output:
对于每组数据n1和n1，计算最大公约数，每个计算结果应占单独一行。 
Sample Input:
6 5 18 12
Sample Output:
1
6

*/

#include <iostream>

int gcd(int a,int b){ 
	if(a<b){//arrange so that a>b 
		int temp = a; 
		a = b; 
		b=temp; 
	} 
	if(0==b)//the base case 
        return a; 
	if(a%2==0 && b%2 ==0)//a and b are even 
		return 2*gcd(a/2,b/2); 
	if ( a%2 == 0)// only a is even 
		return gcd(a/2,b); 
	if ( b%2==0 )// only b is even 
		return gcd(a,b/2); 
	return gcd((a+b)/2,(a-b)/2);// a and b are odd 
} 

namespace ctb
{
	unsigned gcd(unsigned, unsigned);
}

unsigned ctb::gcd(unsigned m, unsigned n)
{
	unsigned times=1u;


	while(1)
	{
		unsigned flag=0;
		if(0==n)return times*m;

		if(m<n)
		{
			unsigned xchg=m;
			m=n;
			n=xchg;
		}

		if(m&0x1u && n &0x1u)
		{
			int tm=m, tn=n;
			m=(tm+tn)>>1;
			n=(tm-tn)>>1;
			continue;
		}

		if(0==(m & 0x1u))
		{
			m>>=1;
			++flag;
		}
		if(0==(n & 0x1u))
		{
			n>>=1;
			++flag;
		}	
		if(2u==flag)
			times<<=1;
		
	}
}


int main(int argc, char* argv[])
{
	unsigned m, n;
	using ctb::gcd;
	while (std::cin>>m>>n)
	{
		std::cout<<ctb::gcd(m, n)<<std::endl;
	}
	return 0;
}
